<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://java.sun.com/jsf/html">

<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>湖南省自来水公司营销管理信息系统</title>

    <link rel="stylesheet" href="../../../css/reset.css" type="text/css" media="screen" title="no title" />
    <link rel="stylesheet" href="../../../css/text.css" type="text/css" media="screen" title="no title" />
    <link rel="stylesheet" href="../../../css/form.css" type="text/css" media="screen" title="no title" />
    <link rel="stylesheet" href="../../../css/buttons.css" type="text/css" media="screen" title="no title" />
    <link rel="stylesheet" href="../../../css/grid.css" type="text/css" media="screen" title="no title" />
    <link rel="stylesheet" href="../../../css/layout.css" type="text/css" media="screen" title="no title" />

    <link rel="stylesheet" href="../../../css/ui-darkness/jquery-ui-1.8.12.custom.css" type="text/css" media="screen" title="no title" />
    <link rel="stylesheet" href="../../../css/plugin/jquery.visualize.css" type="text/css" media="screen" title="no title" />
    <link rel="stylesheet" href="../../../css/plugin/facebox.css" type="text/css" media="screen" title="no title" />
    <link rel="stylesheet" href="../../../css/plugin/uniform.default.css" type="text/css" media="screen" title="no title" />
    <link rel="stylesheet" href="../../../css/plugin/dataTables.css" type="text/css" media="screen" title="no title" />

    <link rel="stylesheet" href="../../../css/custom.css" type="text/css" media="screen" title="no title">

</head>


<body>

<div id="wrapper">

    <#include "../common/header.ftl"/>

    <div id="content" class="xgrid">


        <div class="x12" id="ee">

            <h2>终止工单</h2>

            <div class="height40">
                工单号 <input id="orderno" />
                <input id="go" class="btn btn-small btn-icon btn-find" type="submit" value="查询工单"><span id="cou"></span>
            </div>


            <br/><br/>

            <div class="form label-inline uniform">
                <div class="field"><label for="id">工单号</label> <input id="orderno1" name="fname" size="50" type="text" class="medium" disabled="disabled"  /></div>
                <div class="field"><label for="id">工单类型</label> <input id="ordertype" name="fname" size="50" type="text" class="medium" disabled="disabled"  /></div>
                <div class="field"><label for="id">用户姓名</label> <input id="username" name="fname" size="50" type="text" class="medium" disabled="disabled"  /></div>
                <div class="field"><label for="id">用户地址</label> <input id="address" name="fname" size="50" type="text" class="medium" disabled="disabled"  /></div>
                <div class="field"><label for="id">联系人</label> <input id="linkman" name="fname" size="50" type="text" class="medium" disabled="disabled"  /></div>
                <div class="field"><label for="id">联系电话</label> <input id="phone" name="fname" size="50" type="text" class="medium" disabled="disabled"  /></div>
                <div class="field"><label for="id">当前流程</label> <input id="stepid" name="fname" size="50" type="text" class="medium" disabled="disabled"  /></div>
                <div class="field"><label for="id">最后操作人</label> <input id="lasteditemp" name="fname" size="50" type="text" class="medium" disabled="disabled"  /></div>
                <div class="field"><label for="id">最后操作时间</label> <input id="lasteditdate" name="fname" size="50" type="text" class="medium" disabled="disabled"  /></div>
                <div class="field"><label for="id">已交费</label> <input id="id" name="fname" size="50" type="text" class="medium" disabled="disabled" value="否" /></div>
			<#--<form action="/beOrder/stop" method="post"> </form>-->
                <div class="field"><label for="description">终止原因</label> <textarea rows="7" cols="50" id="abortcause"></textarea></div>
                <div class="buttonrow">
                    <button class="btn" id="stop">确认终止</button>
                    <button class="btn btn-grey" onClick="history.back(-1);">返回</button>
                </div>
			<#--</form>-->
            </div>

        </div> <!-- .x12 -->

    </div> <!-- #content -->

    <div id="footer">
        <div class="content_pad">
            <p>&copy; 2013-11 版权所有 <a href="#">湖南省自来水公司</a>.   技术支持 <a href="#">华瑞教育</a>.</p>
        </div> <!-- .content_pad -->
    </div> <!-- #footer -->

</div> <!-- #wrapper -->

<script src="../../../js/jquery/jquery-1.5.2.min.js"></script>
<script src="../../../js/jquery/jquery-ui-1.8.12.custom.min.js"></script>
<script src="../../../js/misc/excanvas.min.js"></script>
<script src="../../../js/jquery/facebox.js"></script>
<script src="../../../js/jquery/jquery.visualize.js"></script>
<script src="../../../js/jquery/jquery.dataTables.min.js"></script>
<script src="../../../js/jquery/jquery.tablesorter.min.js"></script>
<script src="../../../js/jquery/jquery.uniform.min.js"></script>
<script src="../../../js/jquery/jquery.placeholder.min.js"></script>

<script src="../../../js/widgets.js"></script>
<script src="../../../js/dashboard.js"></script>

<script type="text/javascript">

    $(document).ready ( function ()
    {
        Dashboard.init ();
    });

</script>
<script type="text/javascript">
    $(function () {
        $("#go").click(function () {
            alert($("#orderno").val())
            $.ajax({
                url:"/beOrder/abort",    //请求的url地址
                dataType:"json",   //返回格式为json
                async:true,//请求是否异步，默认为异步，这也是ajax重要特性
                data:{
                    "orderno":$("#orderno").val(),
                },
                type:"POST",   //请求方式
                beforeSend:function(){
                    //请求前的处理
                },
                success:function(req){
                    alert(req)
                    if (req==null) {
                        var f = "<span style='color: red'>用户信息为空</span>";
                        $("#cou").html(f);
                        return false;
                    }else if(req.stepid==-1){
                        var st="<span style='color: red'>工单已被禁用</span>"
                        $("#cou").html(st);
                        return false;
                    }
                    $("#orderno1").val(req.orderno)
                    switch (req.ordertype) {
                        case 1:
                            $("#ordertype").val("新户")
                            break;
                        case 2:
                            $("#ordertype").val("分户")
                            break;
                        case 3:
                            $("#ordertype").val("过户")
                            break;
                        case 4:
                            $("#ordertype").val("换表")
                            break;
                        case 5:
                            $("#ordertype").val("代扣")
                            break;
                        case 6:
                            $("#ordertype").val("重签")
                            break;
                        case 7:
                            $("#ordertype").val("销户")
                            break;
                    }
                    $("#username").val(req.username)
                    $("#address").val(req.address)
                    $("#linkman").val(req.linkman)
                    $("#phone").val(req.phone)
                    switch (req.stepid) {
                        case 1:
                            $("#stepid").val("用户申请")
                            break;
                        case 2:
                            $("#stepid").val("初步审核")
                            break;
                        case 3:
                            $("#stepid").val("交施工费")
                            break;
                        case 4:
                            $("#stepid").val("水费清算")
                            break;
                        case 5:
                            $("#stepid").val("供水协议")
                            break;
                        case 6:
                            $("#stepid").val("施工竣工")
                            break;
                        case 7:
                            $("#stepid").val("通水停水")
                            break;
                        case 8:
                            $("#stepid").val("档案存档")
                            break;

                    }
                    $("#lasteditemp").val(req.lasteditemp)
                    $("#lasteditdate").val(req.lasteditdate)
                    $("#cou").html("")
                },
                complete:function(){
                    //请求完成的处理
                },
                error:function(){
                    //请求出错处理
                }

            });
        })
        $("#stop").click(function () {
            $.ajax({
                url:"/beOrder/stop",    //请求的url地址
                dataType:"json",   //返回格式为json
                async:true,//请求是否异步，默认为异步，这也是ajax重要特性
                data:{
                    "abortcause":$("#abortcause").val(),
                    "orderno":$("#orderno1").val(),
                    "stepid":-1
                },
                type:"POST",   //请求方式
                success:function(succ){
                    $("#ee").find("input,textarea").each(function(){
                        this.value ="";
                    });
                    window.location.href="http://localhost:8090/suces?pagename=abort";

                }
            });

        })

    })

</script>

</body>

</html>